const mysql = require('mysql')
const pool = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: '123456',
    database: 'fxlink',
    port: 3306
})
const query = function (sqlCode, options, callback) {
    pool.getConnection((err, conn) => {
        if (err) {
            callback(err, null, null)
        } else {
            conn.query(sqlCode, options, (err, results, fields) => {
                // 释放连接
                conn.release()
                //事件驱动回调
                callback(err, results, fields)
            })
        }
    })
}
module.exports = query
